{* Smarty *}
{*
 *  This file is part of Urd.
 *
 *  Urd is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *  Urd is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program. See the file "COPYING". If it does not
 *  exist, see <http://www.gnu.org/licenses/>.
 *
 * $LastChangedDate: 2008-07-03 22:46:29 +0200 (Thu, 03 Jul 2008) $
 * $Rev: 1265 $
 * $Author: gavinspearhead $
 * $Id: admin_users.tpl 1265 2008-07-03 20:46:29Z gavinspearhead $
 *}
{include file="head.tpl" title=$title}
<br/><h3>{$title}</h3>
{foreach from=$years item=year}
<a href="stats.php?year={$year}#months">{$year|escape:htmlall}</a>&nbsp;
{/foreach}
{if $show_month > 0}
<a href="stats.php">{$LN_stats_overview}</a>&nbsp;
{/if}

{if $show_year > 0}
<h4>{$LN_stats_peryear}</h4>
{foreach from=$yearstats->Years key=year item=ys}
{* Loop through all years: *}
<h3>{$year}</h3>
	{* See what the maximum is: *}
	{assign var="maxsize" value="0"}
	{foreach from=$ys->Users.__total->StatType key=stattype item=statdata}
	{* Loop through all stats to determine maximum, to use as 100%: *}
		{if $statdata->SizeRaw > $maxsize}{assign var="maxsize" value=$statdata->SizeRaw}{/if}
	{/foreach}
	{if $maxsize == 0}{assign var="maxsize" value="1"}{/if}

	{foreach from=$ys->Users key=username item=userstats}
	{* Loop through all users: *}
	{* If username = '__total', replace it with the right language word *}
	{if $username == '__total'}
	{assign var="username" value=$LN_total}
<table class="totalstats">
	{else}
<table class="userstats">
	{/if}
<tr><td colspan="3" class="statsname">{$username|escape:htmlall}</td></tr>
		{counter start=1 skip=1 assign="offset"}
		{foreach from=$userstats->StatType key=stattype item=statdata}
	{assign var="maxsize" value=$ys->Users.__total->StatType.stats_dl->SizeRaw}
		{* Loop through all stats for this user: *}
        {if $maxsize != 0}
            {assign var="barsize" value="`$statdata->SizeRaw*100/$maxsize*4+0.99999`"} {* x4 for a 400 pixel bar width for 100% *}
        {else} 
            {assign var="barsize" value="1"}
        {/if}

		{* And as Smarty doesn't have a decent way to round off numbers, we'll hax it in: *}
		{capture assign="goodbarsize"}{$barsize|string_format:"%d"}{/capture}

<tr class="stats"><td class="statsleft">{$statdata->Count} {$statdata->StatName}</td>
<td class="statsmid"><div><table class="minimal"><tr class="minimal" height="15"><td class="bar_{$offset} minimal" width="{$goodbarsize}"></td></tr></table></div></td>
<td class="statsright">{$statdata->SizeNice}</td></tr>
		{counter}
		{/foreach}
<tr><td colspan="3" class="statsname"></td></tr>
</table>
	{/foreach}
{/foreach}
{/if}

{if $show_month > 0 }
<a id="months"></a>
<h4>{$LN_stats_permonth} {$month_year}</h4>
{foreach from=$monthstats->Months key=monthnr item=mo}
{* Loop through all years: *}
<h3>{$mo->MonthName} {$month_year}</h3>

        {* See what the maximum is: *}
        {assign var="maxsize" value="0"}
        {foreach from=$mo->Users.__total->StatType key=stattype item=statdata}
        {* Loop through all stats to determine maximum, to use as 100%: *}
                {if $statdata->SizeRaw > $maxsize}{assign var="maxsize" value=$statdata->SizeRaw}{/if}
        {/foreach}

	{if $maxsize == 0}{assign var="maxsize" value="1"}{/if}
	{foreach from=$mo->Users key=username item=userstats}
	{* Loop through all users: *}
	{* If username = '__total', replace it with the right language word *}
	{if $username == '__total'}
	{assign var="username" value=$LN_total}
<table class="totalstats">
	{else}
<table class="userstats">
	{/if}
<tr><td colspan="3" class="statsname">{$username|escape:htmlall}</td></tr>

		{counter start=1 skip=1 assign="offset"}
		{foreach from=$userstats->StatType key=stattype item=statdata}
		{* Loop through all stats for this user: *}
        {if $maxsize != 0}
            {assign var="barsize" value="`$statdata->SizeRaw*100/$maxsize*4+0.99999`"} {* x4 for a 400 pixel bar width for 100% *}
        {else} 
            {assign var="barsize" value="1"}
        {/if}
		{* And as Smarty doesn't have a decent way to round off numbers, we'll hax it in: *}
		{capture assign="goodbarsize"}{$barsize|string_format:"%d"}{/capture}

<tr class="stats"><td class="statsleft">{$statdata->Count} {$statdata->StatName}</td>
<td class="statsmid"><div><table class="minimal"><tr class="minimal" height="15"><td class="bar_{$offset} minimal" width="{$goodbarsize}"></td></tr></table></div></td>
<td class="statsright">{$statdata->SizeNice}</td></tr>
		{counter}
		{/foreach}
<tr><td colspan="3" class="statsname"></td></tr>
</table>
	{/foreach}
{/foreach}
{/if}

<a href="stats.php?year={$years[x]}">{$years[x]}</a>&nbsp;
{include file="foot.tpl"}
